/**
 * @param {string} 
 * @return {boolean}
 */

var validPalindrome = function (s) {
  let arr = s.split('');
  let temp1 = s.split('');
  let temp2= s.split('');
  let i = 0;
  let j = arr.length - 1;
  let maybe = [];
  while (i < j) {
    let A = arr[i];
    let B = arr[j];
    if (A === B) {
      i++;
      j--;
      continue;
    }
    if (A !== B) {
      let rome;
      maybe.push(false);
      temp1.splice(j, 1);
      // 拿掉B 计算一次
      rome = isPalindrome(temp1.join(''));
      if(rome) {
        break;
      } else {
        // 前面拿掉再计算一次
        temp2.splice(i, 1);
        rome = isPalindrome(temp2.join(''));
        if(rome) {
          break;
        }
        maybe.push(false);
        break;
      }
    }
  }
  return maybe.length <= 1;
};

function isPalindrome(s) {
  let arr = s.split('');
  let i = 0;
  let j = arr.length - 1;
  while(i < j) {
    let A = arr[i];
    let B = arr[j];
    if (A === B) {
      i++;
      j--;
      continue;
    } else {
      return false;
    }
  }
  return true;
}

console.log(validPalindrome("abca"))
